A Quarto reveal.js theme

Garth Tarr

The University of Sydney

First section

Random Forest Model

set.seed(5003)

alzdata <- read.csv("alzheimers_disease_data.csv")
alzdata$Diagnosis <- factor(alzdata$Diagnosis, levels = c(0, 1), labels = c("No", "Yes"))
alzdata <- subset(alzdata, select = -c(PatientID, DoctorInCharge))

indices <- createDataPartition(alzdata$Diagnosis, p = 0.7, list = FALSE)
train_dat <- alzdata[indices,]
test_dat <- alzdata[-indices, ]
treemap <- tree(Diagnosis ~ ., data = train_dat)
plot(treemap)
text(treemap)

ntree_seq <- c(1, 50, 100, 400, 500, 700, 800, 900, 1000, 2000)
max.ntree_seq <- max(ntree_seq)
test_diagnosis <- test_dat[["Diagnosis"]]
ranger_model <- ranger(Diagnosis ~ ., data = train_dat, num.trees = max.ntree_seq)
rand.forest.function <- function(x) { 
  predict_ranger <- predict(ranger_model, data = test_dat, num.trees = x)[["predictions"]]
  CM <- confusionMatrix(test_diagnosis, predict_ranger)
  Sensit <- CM$byClass[["Sensitivity"]]
  Specif <- CM$byClass[["Specificity"]]
  Accura <- CM$overall[["Accuracy"]]
  TP <- CM$table["Yes", "Yes"]
  FP <- CM$table["Yes", "No"]
  FN <- CM$table["No", "Yes"]
  precision <- TP / (TP + FP)
  recall <- TP / (TP + FN)
  F1 <- 2 * (precision * recall) / (precision + recall)
  Performance_measures <- list(Sensitivity = Sensit, Specificity = Specif, Accuracy = Accura, F1 = F1)
  }
perf_measures <- map(ntree_seq, rand.forest.function)
specificities <- map_dbl(perf_measures, "Specificity")
plot_data <- data.frame(ntree_seq, specificities)
ggplot(plot_data, aes(x = ntree_seq, y = specificities)) +
  geom_line() +
  geom_point() + 
  geom_text(aes(label = round(specificities, 4)), 
            vjust = -0.5, 
            color = "black", 
            size = 3.5) +
  labs(x = "Number of Trees", y = "Specificity") +
  theme_minimal()

Quarto

Note title

Note text

Tip title

Tip text

Important title

Important text

Asides

Block quote

  • For further details on customisations available see here
  • Icons can be included by installing the fontawesome Quarto extension.

Layouts

Layout

List One

  • Item A
  • Item B
  • Item C
  • Item D

List Two

  • Item X
  • Item Y
  • Item Z

Columns (more customisable)

Left column

Right column

Plots: below code

library(ggplot2)
p1 = iris |> ggplot() +
  aes(x = Petal.Length, y = Petal.Width, colour = Species) + 
  geom_point(size = 4) + theme_classic(base_size = 20)
p1

Plots: hide code using echo: false

Plots: auto two column using output-location: column

p1 = iris |> ggplot() +
  aes(x = Petal.Length, 
      y = Petal.Width, 
      colour = Species) + 
  geom_point(size = 4) + 
  theme_classic(base_size = 30)
p1

Bullets

When you click the Render button a document will be generated that includes:

  • Content authored with markdown
  • Output from executable code

Reference Wickham et al. (2019)

Code

When you click the Render button a presentation will be generated that includes both content and the output of embedded code. You can embed code like this:

1 + 1
[1] 2

Handy R package

The quartostamp R package provides RStudio “Addins” that make life easier for working with Quarto documents. It has a bunch of templates, e.g. for creating

  • callout blocks
  • columns
  • tabsets
  • footnotes
  • pauses
  • speaker notes…

References

Wickham, H., Averick, M., Bryan, J., Chang, W., McGowan, L.D., François, R., … Yutani, H. (2019). Welcome to the tidyverse. Journal of Open Source Software, 4(43), 1686. DOI: 10.21105/joss.01686